/**
 * Created with IntelliJ IDEA.
 * User: ajhin
 * Date: 8/16/13
 * Time: 6:33 PM
 * To change this template use File | Settings | File Templates.
 */
package societyGames.codeAlong.model
{
import societyGames.xmlFragment.XMLFragment;
import societyGames.xmlFragment.XMLFragmentEditList;

public class Function extends XMLFragment
{
  override protected function getDefaultXML():XML
  {
    return _defaultXML;
  }

  public function get name():String
  {
    return _xml.@name;
  }

  [Bindable]
  public function set name(value:String):void
  {
    _xml.@name = value;
  }

  public function get description():String
  {
    return _xml.@description;
  }

  [Bindable]
  public function set description(value:String):void
  {
    _xml.@description = value;
  }

  public function get returnType():String
  {
    return _xml["return"][0].@type;
  }

  [Bindable]
  public function set returnType(value:String):void
  {
    _xml["return"][0].@type = value;
  }

  public function get returnDescription():String
  {
    return _xml["return"][0].@description;
  }

  [Bindable]
  public function set returnDescription(value:String):void
  {
    _xml["return"][0].@description = value;
  }

  [Bindable]
  [FragmentCollection(className="societyGames.codeAlong.model.Parameter", nodeName="parameter")]
  public var parameters:XMLFragmentEditList;

  public function get example():String
  {
    return _xml.example[0].toString();
  }

  [Bindable]
  public function set example(value:String):void
  {
    _xml.example[0].setChildren(value);
  }

  private const _defaultXML:XML =
          <function name="functionName" description="Function description.">
            <return type="bool" description="Return value description"/>
            <parameter name="parameter1" index="1" type="Boolean" description="True to arrest Alex, false otherwise."/>
            <example>functionName(true);</example>
          </function>;
}
}
